#include "I1SectionNumericalCalculator.h"

#include "DataStructure/Common/Real.h"

#include "ISectionNumericalCalculator.h"
#include "SectionCalculator/StandardSectionTool.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::FEMSolver::Element::I1SectionNumericalCalculator;
using SG::FEMSolver::Element::ISectionNumericalCalculator;

void I1SectionNumericalCalculator::Mesh (const PBARLData& section, _OUT Meshes& meshes, int refineLevel) const
{
    /* NASTRAN 的 I1 形梁截面转换成 I 形梁截面
     *
     * I.dim1 = I1.dim4
     * I.dim2 = I1.dim1 + I1.dim2
     * I.dim3 = I1.dim1 + I1.dim2
     * I.dim4 = I1.dim2
     * I.dim5 = (I1.dim4 - I1.dim3) / 2
     * I.dim6 = (I1.dim4 - I1.dim3) / 2
     * 详细请参考 NASTRAN 手册
     */
    Real      dim1{ section.m_dimension[3] };
    Real      dim4{ section.m_dimension[1] };
    Real      dim2{ dim4 + section.m_dimension[0] };
    Real      dim3{ dim2 };
    Real      dim5{ 0.5 * (dim1 - section.m_dimension[2]) };
    Real      dim6{ dim5 };
    PBARLData ISection{ section };
    ISection.m_dimension = { dim1, dim2, dim3, dim4, dim5, dim6 };
    ISectionNumericalCalculator ISecMesher;
    ISecMesher.Mesh (ISection, _OUT meshes, refineLevel);
}